﻿<!DOCTYPE html>
<html>
     <head>
          <meta charset="UTF-8">
          <title></title>
     </head>
		<script>
			//已知字符串“a,a,b,c,c,d,f,g,j,j”编程实现以下功能。
			//统计每个字符出现的次数，结果显示 a 2、b 1、c 2、d1
			//去掉重复的字符，使结果显示 abcdfgj
			var str = "a,a,b,c,C,D,f,g,j,j";
			var list = str.toLowerCase().split(",");
			console.log(list);
			
			for(var asc=97; asc<=122; asc++){
				var s = String.fromCharCode(asc);
				var count = 0;
				for(var i=0; i<list.length; i++){
					if(list[i] == s){
						count++;
					}
				}
				if(count > 0 ) console.log("字母"+s+"出现了："+count+"次");
			}
			
			var newlist = [];
			for(var i=0; i<list.length; i++){
				var flag = "no";//假定不存在
				for(var j=0; j<newlist.length; j++){
					if(list[i] == newlist[j]){
						flag = "yes";
						break;
					}
				}
				if(flag == "no"){
					newlist.push(list[i]);
				}
			}
			console.log(newlist.join(""));
			
		</script>
     <body>
     </body>
</html>
